package com.study.websocket2.contrroller;

import com.study.websocket2.service.impl.DefaultMessageHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author
 */
@RestController
@RequestMapping("/api/ws")
public class WebSocketController {

    @Autowired
    private DefaultMessageHandler messageHandler;

    /**
     * 群发消息内容
     * @param message
     * @return
     */
    @RequestMapping(value="/sendMsg", method= RequestMethod.GET)
    public String sendAllMessage(@RequestParam(required=true) String message,@RequestParam(required=true)String deviceId){
        String result=messageHandler.SySendMsg(deviceId,message);
        if(result==null){
            return "error";
        }
        return result;
    }
}
